Fixed mistake with indexing in the convert function