Hrm, perhaps we should centrailize this logic and error code?