Improved version of agnaldo brodis made in delphi