new version with some optimization related mostly to wx
use