add exceptions and tests. Need a main