Moved return of  outside for loop