Fixed error + added better comments to explain.