Corrected the order of conditions.