The replace of the '\' was only replacing the first one. Changed it to replace all '\'