mixpanel , code refactor