added better key handling system