Moved initialisation outside of loop