Added logic to prevent double responses