minor formatting and more func structuring