move extractions to functions to avoid repeating