refactor stack_mapper