Database query function added