added length check to constructor, added documentation