added toggle of definiton
changed render to redirect_to to avoid problems