added second layer calculation