adding auto refresh function