add loop refresh function