Why isnt my condition working properly?