refactored layer manager