Created extract function