Refactoring in progress, moved random functions to proper angular controller methods