modified
add awhen
add awhen unit-test