added all functionality except PDF generation