added patricks solution