added detailed comments