Yes, I also thought how to make it better, but the trick is I need this code before redirect_to