library codes modular and refactor