Working version. Values slightly off.