Final version. Potential bug fixed.