Refactored to modularize units