abstract out the converstion part so it can be used in other modules