add logic code and test case