cleaned up calculations