Logic Problem using If Statement