Added parse query function