Added length check to pre_cmd