Refactor heartbeat handler into another controller