There is application logic in this method which could be moved out of the API module. The method itself is also to big.