Added function check_special_keys , handlebackspace and clean up the code