Proof involving functions

Prove the following:

If and , then .

Here's my thoughts/attempt:

Proof:

Let A, B, C, and D be sets. Assume and . Let . Since f is a function from A to B, there is some such that . Let be such an element, that is, let such that . Let . Since g is a function from C to D, there is some such that . Let be such an element, that is, let such that .

This is all I have so far.

Would I have to break it into cases where and ? If , contains an element, but if , is empty since a and c were arbitrary. The same argument holds for . So, taking these things into account, is either a function from the set containing a to the set containing b, or its a function from the empty set to the empty set.

Does this make any sense, is it necessary, and how should I write it in my proof?

Thanks in advance.