divide functionality (refactor)