Minor refactor of code. no feature changes