fixed issues with seg fault