added res2double
res2double fixed