implemented coarse to fine matching