Implementation of calculate method