Move threshold calculations to method

#24