Debouncing issues

Use a Hall sensor instead. It does not require debouncing at all.