Refacored code based on flog and bullet