Made open function work with mySQL funciton