minor code refactor before merging issue #5