added check for game boundaries