fixed segment fault bug