added module.exports, and made ononline/onoffline retain previous callback function