potential working solution with history