Adding generic implementation of the STACK