Added Log function and error handling for SMS