fix divide by 0 error
add more conditional logic