add test and refact