convert to function-based calculations
Merge pull request #4 from SameerSarkar/master

convert to function-based calculations