added comments for explaination