seg fault fix (third try)