I think each numbered comment should be it's own function. It would remove the need for the comments :) It'd also shorten this function.