refactoring for using mithril