Make runnable on OSX

Original code may crash on OSX