add gitignore
Move ifs where can be evaluated early