clean up and reformatting code