refresh function in, needs debugging