Initial working version

Working version with comments