commented and simplified