fully functional code for this portion