polish and fix bugs