code-cleaning and fixed update