nearly
refactored