lib: support functions