added to firebase, added directives, put all logic into promise