started implementing algorithm