finished implementing is_balanced