Working version - not sure why it works