Error message is showing even when conditions are met.