Udating code with Charlie's recommended changes...