Last working version with comments