move success into its own function