changed object() function to make it consistent with spawn()