modified divide method