bugfix to work for for all map sizes