Refactored lib