While you were taking it, you did not cure your insomnia, which is the reason you needed to take it to begin
with, so now that you stopped taking the
Ambien, you are having the problem again.
There has to be a reason for your sleeping disorder i.e. anxiety, depression, sleep apnea, stress, use of stimulant intake late in the day (caffeine) or lack of intellectual stimulation during the day. There are multiple medical, psychological, dietary and pharmaceutical reasons for poor sleep.