bug fixes and add multiple loop.