refactoring - evaluating url before sending it to the api