adding heap functions from lecture