Initial convertion to SQL method