refactor for #14 and #15