refactoring to parse api