algo refact