Should do error handling a bit better