changed some fence algo stuff