updated to a better working version