Fixed bug when refreshing page