FlipGA algo implementation