move correct calculations to the main function