fix undefined function and add integer divisions