Write functions in a more portable way