Moved rest invocation into a separate method to make it easier to read code