Refactored convert class to simplify code