use extract function instead of manually extracting parameters