first version of phase respecting algorithm