Improved algorithm

- significantly cleaned up the code
- now future-imports division lib
- thx hop!