tidied and amended class structure