added better parametre validation