Changed conditional statements around to make more sense in procedure method.