add windows path support
add error handling and fix index