move conversion to a function