better integration with existing code; removed explicit SQL calls