moar logic and exception handling