Fixes the refresh loop