some modification and commenting