merging code from windows fix to Mac