Tidied slightly and added example