Code for RANSAC