refactor extend logic