refatored security