changes from @timfel