updated functions for PA2 v.2