implementation of cons list