break up main fn
reindent
brek up fn
generalise
rm redundant unit