changed some return statements to return zero instead of null