more branch insts; refactor the main loop