Got a working version, need to test extensively now
updated example