solution for stack