refactoring with math!