Looping within a case statement