completed code for APT Set 1