remove some spaces
throw if elems arg is not provided