cleaned up code with separate background service to send messages and separate class to monitor heart rate