loop and switch