Cleaned up ambiguous for loop to avoid compiler warnings and code clarity