new working win logic with binary code