Moved parsing code into controller