Integrate previous comments into working code