prototype ready, now to rewrite