End logic