Fix if-statement that always evaluates True