Attempt 2 bugfix for when agent is Nil