Working version with adaptions