added some sql functionality