another refactor
refactors finished; now margins are more reliable