refactored layer add/remove