refactor/clean: extract methods for lowering the complexity