Bugfix: move null check