fred algorithm