added more implementation & clean more comments