formatting and comments improved