fixed function zero division bug