First working version with options