rewrite using reactor pattern