complete rewrite,sooo much better