improved error checking

- added nargin check
- changed returned error statement for length check