Adding in basic error handeling