Refactored to allow for conversion to other formats