Replaced hacky solution for bad goal value calculation with clean solution courtesy of Alex