added maxlen variable so the script will be easier to amend for adn. ha ha.