refactor library functions.