added SQL save functionality