1. Rewrite directionarysearch with better structure

2. add three code mode