moved res.write above render