Integrated with AJ's code