added algorithm functions to util.py, to be tested