fixed a divide by zero
fixed normalization