implement ugly cross platform utils