moved library calls to top of script