code tidy and fix