misc function for c