bugfix - changed double to int for NX and NY in all functions