Cleaned up the output and added domain checking