Moving code from views to signals