refactor, remove heap mem