fix bugs in linux and mac