Fixed subtle seg fault