refactor to use instance variables