fixed errors with database