move code to rake task