Fixed the segfauly issue