using arrays for popped elements. Doesn't fully work yet