Refined convert.js by removing regex duplication