databse logic added