implementing calculate method