A version that seems to work