Fixing segfault in case of empty input