functioning main script