refactoring based on origin docs