This should do it. Some cleanup needed