runtimeerror working outside of application context