fix registerBlock bug, simplify code