added some validateion to database operations