Fixed bug in if condition to check whether it should run when a message was received or a shared var updated.