add special handling if value == 0
code cleanup