final version. missing comments