rewrites append function; it still doesn't work, but it might be closer