seg fault fix (second try)