Code rewrite part 2