refactoring + stack