Added loop type option