I believe you should create a function in models and put lines 16, 17 inside.