unsafe cast bugfix