merge codings and fix bugs