improved usage as a library