code cleaned with comments