refactored small. add comments