Refactor with some added functionality for invite freind feature.