Added functionality
Optimized to constant time
Addded user interface
Merge branch 'optimize'