refactor the dashboard logic