fix to hps function