needs work possible rewrite