Moved function cleanGroups to use map
Refactored timesToInterval