Added stock calculations
Code refactoring