some refactoring
add pred_matching, key_matching, fix bug with result binding