refactored divide