improved division detection