added better validation