Refactor http service