Changes to make it compatible with both iOS and Mac OS