code tidy and comments