Implemented calculate method.