improved logic for work by mac