add some verifications & code comments