Integrate functions into script to remove dependency on external scripts