enhance  merge cells and collapse cells function and clean up codes