Fixed Joey's and Florian's code