implemented function. still untested