Replaced deprecated query function