Shift logic to ASM- fixed bugs v2.0