working code, buggy firing