Changed some of the code around