updated parser with setTail. might not work well though.