fixed bugs from static rearrangement