moved focus checking to JavaScript