Let X be a topological space and A, a dense subset. Let f: A-->Y be a continuous function where Y is regular. Further assume that for x in A, if lim x = y then lim f(x) exists. Now define a function g: X-->Y by defining g(y) = lim f(x) as x-->y . Show that g is continuous on X.

This question has me stumped. I'd appreciate any help on this.