Commented and simplified slightly