whats the correct one?

when he got home, he took off his tie

a. al llegando a casa, se quito la corbata

b. al llegar a casa, se quito la corbata