oops: some code refactoring
add: separate module for library functions