Streamlined Code to make it more functional
Created a library from all function definitions