fixed code that produces an error
fix collision entries when removing layer