code clean up and reusability