cleaned up code except for banded