convert some unique math
refactor some code
rename some vars