looping function not withing funtion, cleaner code. Debuging why more than 2 messages are being sent per loop