added calculations, still buggy