fixed and working version