added len handler (and refactored)