fixing up error handling i hope