begin work on tidying main