refactored, altho tests are red
fixed the key too long problem I'm pretty sure