Modifed function name
Added backtrack version and improved test cases