movestack implementation