Made db global variable. Fixed all -> parameters.