Bug in javascript to select stuff created