refactored trip maker javascript