Full rewrite with own promise API