Working code - first version.