Updated documentation and fixed undefined variable