Refactored partial code for library control panel