Fixed the beacon position being incorrect and simplified the code
Fixed compile error