Working refactored lib