fleshed out most of the functionality