REFACTORed code