Fixes #3744

fixing problems i created #3744 , top coder 2014