updated topcoder solution