Combined code in version 2