Refactory code