cleanup code, fix statuscode error