My conditions are not working as expected