some code reformatting for better reading