moved to lib and test with improved example