fixed stat else/if so it works on Mac OS X