added pandoc pdf output and cleaned code