fix shebang + add a better, more correct math