Fixed segmentation error thanks to Roland Schregle