Correct mistakes and remove loops