Updated to have better logic

also fixed .gitignore