Fixes to code worked

proceed to comenting code to explain work