Add select query function