Trying to clean up for better error checking