updated comments and code