improved snip function