refactored append