Improved heartbeat detection failure logic

Added null value handling