Refactory. Implementing calculation and result layout