augmenting functionality for UI and cleaning up code