more updated for proper pdf creation