Updated to throw invalidArguments correctly