in reply to returns not working

I don't see any reason why it would do what you say. Are you sure CheckDeployed isn't called more than once? You could verify this by adding warn("Called CheckDeployed.\n") as the first line of the function.