refactor to use newer api and dryify url queries