adding initial solution with comments

changed code and added comments