Beam detection working almost perfectly. Small fixes to come up