modified based on comments