add partial and refactor code