very ugly version but with basic functionality definetely refactor