modified from mac