Minor fix and refactor