Added if conditional to the code.