Modified calculations to accomodate database's data's format

Changed equations because database will store partially pre-calculated data.