Fixed comments and added end code