made changes based on comments; added test case