updating code after refactor attempt