Tidying up for loop code and spelling