improve database class