Fixed bugs in divide