Reduce code by moving common processes to methods
Signed-off-by:Arie <arieclaassens@gmail.com>