fix bug, and support cross-platform