improved arg checking and performance