made it somehow more functional. removed all mutable maps