add code to Main
update det code
add test cases