refactor life func