Refactor library to only two functions