fixed validation (should work better)