reorganizing and setting up auto-refresh