move $location logic from model to controller