Version 2 with intelligent algo