Can be refactored to a before_filter ;)