Updated printElements function.