copied from fireangular repo