added copy function, modified snip