tweaking the status codes and trying to functionify things to make it work better