Improved printdetails function