Added check for the instance of the CartPosition class