Fix muddled if statement