code changes based on Victor's approach