added an if statement in scaleVal() to ensure no divide by zero errors