moved code to run method and set variables in constructor