trying to implement MST