Modified original code.