finished functions. untested