Fixed flawed logic