Charmed hadron production in an improved quark coalescence model