Updated prevent algorithm