Fixed div by 0 bug