some minor bugs in the new implementation fixed