bug fix, div by 0, clean code