Updated to allow for variable map sizes