fixed scope error by casting totT to an int rather than flooring it