Creating custom promises using $q