completed function working; still need to add tests