Added try-catch block to prevent invalid input.
0.5.1