fixed error and reorganized dbhandler class