cleaned up is_double code