updated code for mac.