added a printing method for debugging
merged with David's