Added exception handling for improper usage