Added better trip separation code