Tidied code. Added minimised script