implement the guarding functionality