first complete version of the getPI function

applicable & apply PI to atoms