check for Nil result before running sub