refactored detecting adjust size of FP and SP