added test and simplified