optimized roberts slow code