Enhanced N queens code