final code from lahacks