fix bug when refreshing page