Build 2 functions and change few vars names

Build 2 functions and change few vars names