Moved everything into the success function