creating multi query function