refactored convert method