add the rest of the functionality (accidentally forgot in last commit)