Updated with working cursor