added matching and cleaned up