second version, first one with shift registers