Fixed bugs and changed convertor function to use regex