refactored the life example sample