check for presence of layers before iterating them