fixed input detection logic