Added check for same array length; added comments