Merged. Wrote generateId function