modified for mac os x