Tidied extract function