bug fix with segfaults in non-ubuntu Linux