added test input file from email and bit of cleaning old code