added approximate algorithm