Improve Function Detection