updated with more detailed comments