Fixed wrong if condition placement