change pragma once to header guard, refractor code