Changed around the if function

Maybe this will fix the error? I hope it does.