added two more optimalizations for consecutive numbers