split the library script into a reusable database/reporting layer