How can I improve the inside of this library?