added status codes and illegal request checking