fixed calculations and various changes