```\nfunction buy(uint256 \_amount, address \_tokenReceiver) public whenNotPaused nonReentrant {\n // rounding up to the next whole number. Investor is charged up to one currency bit more in case of a fractional currency bit.\n uint256 currencyAmount = Math.ceilDiv(\_amount \* getPrice(), 10 \*\* token.decimals());\n\n (uint256 fee, address feeCollector) = \_getFeeAndFeeReceiver(currencyAmount);\n if (fee != 0) {\n currency.safeTransferFrom(\_msgSender(), feeCollector, fee);\n }\n\n currency.safeTransferFrom(\_msgSender(), currencyReceiver, currencyAmount - fee);\n \_checkAndDeliver(\_amount, \_tokenReceiver);\n\n emit TokensBought(\_msgSender(), \_amount, currencyAmount);\n}\n```\n