rewrite for multi-os support.