refactored library processing