make heartbeat listen a standalone thread
documentation