optimize database class