commented code. Final version.