v 1.2
Optimized code and added exceptions