rewrite isOnDet function to test for arbitrary layers