added sql functionality