fixing a bug on lose focus