Logic For A Loop