Database query code added