Bug Fix in key handler