working version with documentation and example