Added email to be sent when door and motion sensor and updated and ordered queries to get the latest first