Fix for loop in layers_manager