added length check
Merge pull request #4 from basyura/check_length