Added 'send_events' boolean argument to the function