Refactoring #2

Signed-off-by: katlogic <kat@lua.cz>
Rewrite #3

Signed-off-by: katlogic <kat@lua.cz>