implementation for slow division and error check