Problem heart rate sensor accuracy

Hi.
For a university project, I am using a heart rate sensor (the one on the pulse sensor website)

I tried the basic example it has, but the pulse it takes is not quite perfect. I would like to know if someone here has a code using that sensor that measures a more accurate and not so random heart rate.

Pd: I have no money to buy another pulse sensor model.

I would also like to know how to differentiate when a person touched the sensor or not.

Thank you!