Moving object generation into the functions.