fixed document formatting & added event for before upload