return null when target_id is false

There is no point to check the database if target_id is false. This
commit comes with a unit test