Changed to while loop
Added error handling for address history