histogram working but code needs serious tidying