Cleaned up the DoRefresh function to be more accurate and to flow better