refactor out cell handling to separate method