working but very messy