Updated SQL Implementation