Refactoring done. Ready for testing