started implementing algorithm in private methods