Not sure you need this whole if/else structure.  Should be able to get the "same" thing out of

```
var retVal = {};
if (start != null) {
  retVal['$gte'] = start;
}

if (end != null) {
  retVal[$lt] = end
}

return retVal
```