Final version with code