code is changed according with comments