Broke down logic of string for time interval