Fixing wrong if statement