rewrite to have a working version