refactor task key getter to Task class