fix seg fault / scalability