gap functionality added. Now the gap value can be passed as an argument