Fixed Stacktrace, continued with making database global