Added more code and comments