refactoring track_user method