Gh384 checkout

duplicated code in first and last if, concatenate them