calculating based on three fields