A general function to create entries.
Removed duplicated code.