better handling of lengths