tidied up and started implementation