tidy up code as recommendation from eliot