huge refactor (clientside)