I think there is probably a cleaner Scala foo way of doing this that @gklopper will know.