working commented code