refactor extent function and export