Add base code provided by Jose Pereira