changed some variables and fixed a conversion bug