refactor code for readability and safety;
v1.0.1;