refactored conversion functions with generic conversion function and associated functors