working upgraded version with notes