some error handling and new rake task