fixed segmenation fault