corrected database implemenation, made it singleton