Corrected bugs in ASPG function

Correction to Dorleta's last changes