add head and tail functions