Moved the function calculating the rhythm into a .js file