improved validation