Extract common code
Common code