modified to support mac enviroment