Edited HeartRateMonitor.c for efficiency