working version but having bug to fix