Added error handling for ActiveRecord::RecordNotFound