Refactor units
Fix bug