Updated for mac compatibility