fixed error in total fun causing weird bugs