Move calculation of signal strengh into a function