added corner case for z<=3