Changed to python implementation