added method to be used for reverse polish notation calculations