tidying up legacy code