move OSX specific code into block