Cleaned up some methods added some error handling