Commit bug#4

I fixed bug #4 . I changed this line of code and added exception handling.