Refactor code

Signed-off-by: Vlad <vg@vladgh.com>