fixed mathematical error