Refactor check for required libraries