added proper modulo function. fixes #37.