Categories algorithm done