working version with query params