Revert "Remove redundant code"

This reverts commit 115d8ba70cb423b3086b510f3a1fd8d5157d9330.
Added some useful comments