Updated with comments as to the problem and solution