Basic functions revised to fixed segmentation fault