added length check for input (throws exception)