Fixed some formatting and added error mesages