Refactored code making it more RESTfull