span refactoring