Update sms-connector.js

Tried to clean up some code and macke it more robust. (its still a bit messy)