fixed compilation but segfaults