rearranging. fixing null/0 case