Improve dashboard code