Progress on refactoring
Extract functions