Move if inside of anonymous function