trying to refactore stuff out of controller into directive