changed Math.rint to Math.floor according to Lua behaviour