alter callback and socket code