cleaned up most of the error check problems