fixed error when only 1 message, and added comments