updated remove function

remove function is good for now, might find bugs later, added comments
and did some tests