working version with registry