refactor so that it does not mantain state between requests