fixing sql connect function & removing old code