make writing to response code more concise

also fixed some whitespace issues