add security to remove method, fix bugs