update codes with tidied comments