Lib-ify the code