add testing
refine some code