I think this is correct now PLEASE TEST...