added keep alive mechanism