fixed s.agent function